import { computed} from "vue";

export function useTodo(proxy){
    //const {proxy} = getCurrentInstance() // 获取调用该方法的vue实例
    const todoArray = computed(()=>{
        return proxy.$store.state.todoArray
    })
    const updateTodo = (payload)=>{
        proxy.$store.commit('SET_TODO_ARRAY',payload)
    }
    return {
        todoArray,
        updateTodo
    }
}

export function useFinished(proxy){
    const finishedArray = computed(()=>{
        return proxy.$store.state.finishedArray
    })
    const updateFinished = (payload)=>{
        proxy.$store.commit('SET_FINISH_ARRAY',payload)
    }
    return{
        finishedArray,
        updateFinished
    }
}

export function useKeepTimes(proxy){
    const keepTimes = computed(()=>{
        return proxy.$store.state.keepTimes
    })
    const updateKeepTimes = (playload)=>{
        proxy.$store.commit('SET_KEEP_TIMES',playload)
    }
    return {
        keepTimes,
        updateKeepTimes
    }
}